﻿
var UserAccount;
if (!UserAccount) {
    UserAccount = {};
}
UserAccount.Init = function () {

    //删除
    $(".dele").live('click', function () {
        var href = $(this).attr("href");
        $.ActionResponse('information', '提示', '确定删除吗？', function () {
            $.post(href, function (data) {
                if (data.success) {
                    window.location.reload(true);
                } else {
                    $.ActionResponse('error', '提示', "错误信息：" + data.data);
                }
            }, 'json');

        });
        return false;
    });

    var href = $(".search").attr("href");
    $(".datalist").load(href, function (data) {
        $("#pageNum").paginate({
            count: $("#tbdatalist").attr("pagecount"),
            start: $("#tbdatalist").attr("pageindex"),
            display: 10,
            border: false,
            text_color: '#888',
            background_color: '#EEE',
            text_hover_color: 'black',
            background_hover_color: '#CFCFCF',
            onChange: function (page) {
                var chageurl = href.replace(href.substring(href.indexOf('=') + 1, href.indexOf('&')), page);
                loadPage(chageurl);
            }
        });
    });

    function loadPage(href) {
        $(".datalist").load(href, function (data) {
            $("#pageNum").paginate({
                count: $("#tbdatalist").attr("pagecount"),
                start: $("#tbdatalist").attr("pageindex"),
                display: 10,
                border: false,
                text_color: '#888',
                background_color: '#EEE',
                text_hover_color: 'black',
                background_hover_color: '#CFCFCF',
                onChange: function (page) {
                    var chageurl = href.replace(href.substring(href.indexOf('=') + 1, href.indexOf('&')), page);
                    loadPage(chageurl);
                }
            });
        });
    }
};
